package com.woniu.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniu.model.Result;
import com.woniu.controller.form.EmployConfirmForm;
import com.woniu.controller.form.RefuseConfirmForm;
import com.woniu.service.ConfirmService;
import com.woniu.service.param.EmployConfirmParam;
import com.woniu.service.param.RefuseConfirmParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2024年05月23日
 */
@RestController
@RequestMapping("/confirm")
@Api(tags = "站点确认相关接口")
public class ConfirmController {
    @Resource
    private ConfirmService confirmService;

    /**
     *站点确认废品
     * @param confirmId 确认表id
     */
    @GetMapping("/locationConfirm/{confirmId}")
    @ApiOperation("站点确认废品")
    public Result<?> locationConfirm(@PathVariable("confirmId") Integer confirmId) {
        confirmService.locationConfirm(confirmId);
        return Result.newInstance(null).setMessage("站点确认成功!").setCode(200);
    }

    /**
     *站点确认废品
     * @param form
     * return null
     */
    @PostMapping("/locationRefuseConfirm")
    @ApiOperation("站点驳回废品")
    public Result<?> locationRefuseConfirm(@RequestBody RefuseConfirmForm form) {
        confirmService.locationRefuseConfirm(BeanUtil.toBean(form, RefuseConfirmParam.class));
        return Result.newInstance(null).setMessage("站点驳回成功!").setCode(200);
    }

    /**
     *员工确认废品
     * @param form
     * return null
     */
    @PostMapping("/employRefuseConfirm")
    @ApiOperation("员工确认废品")
    public Result<?> employRefuseConfirm(@RequestBody EmployConfirmForm form) {
        confirmService.employRefuseConfirm(BeanUtil.toBean(form, EmployConfirmParam.class));
        return Result.newInstance(null).setMessage("员工确认成功!").setCode(200);
    }
}

